const download = (data, name = '列表') => {
    const blob = new Blob([data])
    const fileName = name + '.xlsx'
    // 允许用户在客户端上保存文件
    if (window.navigator.msSaveOrOpenBlob) {
        navigator.msSaveBlob(blob, fileName)
    } else {
        const link = document.createElement('a')
        link.href = window.URL.createObjectURL(blob)
        link.download = fileName
        link.click() // 模拟在按钮上实现一次鼠标点击
        window.URL.revokeObjectURL(link.href) // 释放 URL 对象
    }
}

export default download